package com.cyq.day14.classWork3;

import java.util.Scanner;

public class Fight {
    Monster monster=new Monster();
    PickHero pick=new PickHero();
    Hero hero=new Hero();
    Scanner scanner=new Scanner(System.in);
    public void fight(){
        hero=pick.pickHero();
        monster.hp= (int)(Math.random()*300+200);
        monster.atk=(int)(Math.random()*20+10);
        System.out.println("你遇到的怪兽生命值为："+monster.hp+"攻击力为:"+monster.atk);
        while (hero.hp>0&&monster.hp>0){
            heroTurn();
            monsterTurn();
        }
        if (hero.hp<=0){
            System.out.println(hero.name+"挂了");
        }
        if (monster.hp<=0){
            System.out.println("胜利");
        }
    }
    public void heroTurn(){
        System.out.println("------------英雄的回合---------------");
        System.out.println("你本回合要1.攻击 2.使用英雄技能(消耗30mana)");
        int input=scanner.nextInt();
        if (input==1) {
            System.out.println(hero.name + "攻击造成了" + hero.atk + "点伤害");
            monster.hp -= hero.atk;
            System.out.println("怪物还剩" + monster.hp + "血");
        }
        if(input==2){
            if (hero.name.equals("德玛西亚之力")){
                if (hero.mp<30){
                    System.out.println("蓝不够用");
                    return;
                }
                System.out.println(hero.name+"使用了技能审判");
                if (monster.hp<hero.hp){
                    monster.hp-=100;
                }else{
                    monster.hp-=50;
                }
                hero.mp-=30;
                System.out.println("怪物还剩" + monster.hp + "血");
            }
        }
    }
    public void monsterTurn(){
        System.out.println("------------怪兽的回合---------------");
        System.out.println("怪兽攻击造成了"+monster.atk+"伤害");
        hero.hp-=monster.atk;
        System.out.println("英雄还剩"+hero.hp+"血");

    }
}
